//
//  titleTableViewCell.m
//  hainingOASystem
//
//  Created by michael on 2017/11/17.
//  Copyright © 2017年 czd. All rights reserved.
//

#import "titleTableViewCell.h"

@implementation titleTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.bgView  = [[UIView alloc]init];
 _label1 = [[UILabel alloc]init];
    _label1.frame = CGRectZero;
                    _label1.numberOfLines = 0;

      [_label1 setFont:[UIFont systemFontOfSize:14]];
       [self.bgView addSubview:_label1];
    
       _label2 = [[UILabel alloc]init];
    _label2.frame = CGRectZero;
    _label2.numberOfLines = 0;
      [_label2 setFont:[UIFont systemFontOfSize:12]];
       [self.bgView addSubview:_label2];

}

return self;

}
- (void)layoutSubviews{
[super layoutSubviews];
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"title"] font:12 minsWidth:10+120];
    self.bgView.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView.layer.shadowOffset = CGSizeMake(1,1);
    self.bgView.layer.shadowOpacity = 0.3;
    self.bgView.layer.shadowColor = [UIColor blackColor].CGColor;
        self.bgView.layer.cornerRadius = 5;

    [self.contentView addSubview:self.bgView];
if (titleSize<60) {
  self.bgView.frame =  CGRectMake(5, 5, KScreenWidth - 10, 70);

_label1.frame =CGRectMake(10, 0, KScreenWidth-10-120, 60);
}else{
  self.bgView.frame =  CGRectMake(5, 5, KScreenWidth - 10, titleSize+10);

_label1.frame =CGRectMake(10, 0, KScreenWidth-10-120, titleSize);

}
_label1.textAlignment = NSTextAlignmentLeft;

_label1.textColor = [UIColor blackColor];//其中textColor要用UIColor类型
_label1.text = [NSString stringWithFormat:@"%@",_dic[@"title"]];

_label2.frame =CGRectMake(_label1.right, _label1.top,100, 60);
_label2.textColor = [UIColor grayColor];//其中textColor要用UIColor类型
_label2.textAlignment = NSTextAlignmentRight;
NSString *string =[NSString stringWithFormat:@"%@",_dic[@"updateTime"]];
string = [string substringToIndex:10];//截取掉下标7之后的字符串

_label2.text =string ;

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
